//
//  ZYCCourseRegistrationDetailsViewController.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/26.
//

#import "ZYCCourseRegistrationDetailsViewController.h"
#import "ZYCCourseRegistrationDetailsCell.h"
#import "ZYCCourseRegistrationDetailModel.h"
#import "ZYCNoDataView.h"
@interface ZYCCourseRegistrationDetailsViewController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) ZYCNoDataView *noDataView;

@end

@implementation ZYCCourseRegistrationDetailsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"报名详情";
    [self.view addSubview:self.tableView];
    if (self.model.studentInfos.count == 0) {
        self.tableView.hidden = YES;
        self.noDataView.hidden = NO;
    }else{
        self.tableView.hidden = NO;
        self.noDataView.hidden = YES;
    }

}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return self.model.studentInfos.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZYCCourseRegistrationDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([ZYCCourseRegistrationDetailsCell class]) forIndexPath:indexPath];
    cell.model = self.model.studentInfos[indexPath.section];
    return cell;
}

-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 5;
}

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 72.0;
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}

- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:NO];

}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, kNavBarAndStatusBarHeight, kScreenWidth, kScreenHeight- kNavBarAndStatusBarHeight) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerClass:[ZYCCourseRegistrationDetailsCell class] forCellReuseIdentifier:NSStringFromClass([ZYCCourseRegistrationDetailsCell class])];
    }
    return _tableView;
}


- (ZYCNoDataView *)noDataView {
    if (!_noDataView) {
        _noDataView = [[ZYCNoDataView alloc] initWithFrame:self.tableView.frame];
        _noDataView.hidden = YES;
        [self.view addSubview:_noDataView];
    }
    return _noDataView;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
